package com.yanqu.road.logic.activity.GuaGiftsConfig;

import com.yanqu.road.entity.activity.ActivityConfig;
import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.pasture.PastureUserData;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class GuaGiftsConfig {
    private int activityId;
    private ActivityInfo activityInfo;

    private int GUAGIFTS_LOVE_LETTER_ID = 123551;//情书id
    private int GUAGIFTS_PAPER_CRANES_ID = 123552;//千纸鹤id
    private int GUAGIFTS_JEWELRY_ID = 123553;//金银首饰id

    private int GUAGIFTS_PAPER_ID = 123554;//纸巾id
    private int GUAGIFTS_SOUR_LEMON_ID = 123555;//酸柠檬id
    private int GUAGIFTS_DOG_FOOD_ID = 123556;//精装狗粮id

    /**
     * 广播随机奖励池
     */
    private List<List<Property>> broadcastReward = new ArrayList<>();
    /**
     * 广播领奖有效时间分钟
     */
    private int BROADCASTING_TIME = 20;
    /**
     * 赠送记录页签人数
     */
    private int GIVE_AWAY_RECORD = 20;
    /**
     * 广播宣言固定文本
     */
    private String BROADCASTING_CONTENT = "广播宣言固定文本";
    /**
     * 礼物上限
     */
    private int GIFT_LIMIT = 99;

    public GuaGiftsConfig(ActivityInfo activityInfo, Map<String, ActivityConfig> activityConfigMap) {
        this.activityId = activityInfo.getActivityId();
        this.activityInfo = activityInfo;

        this.GUAGIFTS_LOVE_LETTER_ID = activityConfigMap.get("GUAGIFTS_LOVE_LETTER_ID").getIntValue();
        this.GUAGIFTS_PAPER_CRANES_ID = activityConfigMap.get("GUAGIFTS_PAPER_CRANES_ID").getIntValue();
        this.GUAGIFTS_JEWELRY_ID = activityConfigMap.get("GUAGIFTS_JEWELRY_ID").getIntValue();
        this.GUAGIFTS_PAPER_ID = activityConfigMap.get("GUAGIFTS_PAPER_ID").getIntValue();
        this.GUAGIFTS_SOUR_LEMON_ID = activityConfigMap.get("GUAGIFTS_SOUR_LEMON_ID").getIntValue();
        this.GUAGIFTS_DOG_FOOD_ID = activityConfigMap.get("GUAGIFTS_DOG_FOOD_ID").getIntValue();

        this.BROADCASTING_TIME = activityConfigMap.get("GUAGIFTS_BROADCASTING_TIME").getIntValue();
        this.GIVE_AWAY_RECORD = activityConfigMap.get("GUAGIFTS_GIVE_AWAY_RECORD").getIntValue();
        this.BROADCASTING_CONTENT = activityConfigMap.get("GUAGIFTS_BROADCASTING_CONTENT").getValue();

        this.broadcastReward = PropertyHelper.parseNewStringToPropertyList(activityConfigMap.get("GUAGIFTS_BROADCASTING_REWARD").getValue());

        this.GIFT_LIMIT = activityConfigMap.get("GUAGIFTS_GIFT_LIMIT").getIntValue();

    }


    public int getActivityId() {
        return activityId;
    }

    public ActivityInfo getActivityInfo() {
        return activityInfo;
    }

    public int getGUAGIFTS_LOVE_LETTER_ID() {
        return GUAGIFTS_LOVE_LETTER_ID;
    }

    public void setGUAGIFTS_LOVE_LETTER_ID(int GUAGIFTS_LOVE_LETTER_ID) {
        this.GUAGIFTS_LOVE_LETTER_ID = GUAGIFTS_LOVE_LETTER_ID;
    }

    public int getGUAGIFTS_PAPER_CRANES_ID() {
        return GUAGIFTS_PAPER_CRANES_ID;
    }

    public void setGUAGIFTS_PAPER_CRANES_ID(int GUAGIFTS_PAPER_CRANES_ID) {
        this.GUAGIFTS_PAPER_CRANES_ID = GUAGIFTS_PAPER_CRANES_ID;
    }

    public int getGUAGIFTS_JEWELRY_ID() {
        return GUAGIFTS_JEWELRY_ID;
    }

    public void setGUAGIFTS_JEWELRY_ID(int GUAGIFTS_JEWELRY_ID) {
        this.GUAGIFTS_JEWELRY_ID = GUAGIFTS_JEWELRY_ID;
    }

    public int getGUAGIFTS_PAPER_ID() {
        return GUAGIFTS_PAPER_ID;
    }

    public void setGUAGIFTS_PAPER_ID(int GUAGIFTS_PAPER_ID) {
        this.GUAGIFTS_PAPER_ID = GUAGIFTS_PAPER_ID;
    }

    public int getGUAGIFTS_SOUR_LEMON_ID() {
        return GUAGIFTS_SOUR_LEMON_ID;
    }

    public void setGUAGIFTS_SOUR_LEMON_ID(int GUAGIFTS_SOUR_LEMON_ID) {
        this.GUAGIFTS_SOUR_LEMON_ID = GUAGIFTS_SOUR_LEMON_ID;
    }

    public int getGUAGIFTS_DOG_FOOD_ID() {
        return GUAGIFTS_DOG_FOOD_ID;
    }

    public void setGUAGIFTS_DOG_FOOD_ID(int GUAGIFTS_DOG_FOOD_ID) {
        this.GUAGIFTS_DOG_FOOD_ID = GUAGIFTS_DOG_FOOD_ID;
    }

    public Property getBroadcastReward() {
        return PropertyHelper.randomPropertyByListList(broadcastReward);
    }

    public void setBroadcastReward(List<List<Property>> broadcastReward) {
        this.broadcastReward = broadcastReward;
    }

    public int getBROADCASTING_TIME() {
        return BROADCASTING_TIME;
    }

    public void setBROADCASTING_TIME(int BROADCASTING_TIME) {
        this.BROADCASTING_TIME = BROADCASTING_TIME;
    }

    public int getGIVE_AWAY_RECORD() {
        return GIVE_AWAY_RECORD;
    }

    public void setGIVE_AWAY_RECORD(int GIVE_AWAY_RECORD) {
        this.GIVE_AWAY_RECORD = GIVE_AWAY_RECORD;
    }

    public String getBROADCASTING_CONTENT() {
        return BROADCASTING_CONTENT;
    }

    public void setBROADCASTING_CONTENT(String BROADCASTING_CONTENT) {
        this.BROADCASTING_CONTENT = BROADCASTING_CONTENT;
    }

    public int getGIFT_LIMIT() {
        return GIFT_LIMIT;
    }

    public void setGIFT_LIMIT(int GIFT_LIMIT) {
        this.GIFT_LIMIT = GIFT_LIMIT;
    }

    public boolean isRightGift(int giftType, int giftId) {
        if (giftType == 1) {
            if (giftId == getGUAGIFTS_LOVE_LETTER_ID() ||
                    giftId == getGUAGIFTS_PAPER_CRANES_ID() ||
                    giftId == getGUAGIFTS_JEWELRY_ID()) {
                return true;
            }
        } else if (giftType == 2) {
            if (giftId == getGUAGIFTS_PAPER_ID() ||
                    giftId == getGUAGIFTS_SOUR_LEMON_ID() ||
                    giftId == getGUAGIFTS_DOG_FOOD_ID()) {
                return true;
            }
        }
        return false;
    }

    public int getGiftTypeByGiftId(int giftId){
        if (giftId == getGUAGIFTS_LOVE_LETTER_ID() ||
                giftId == getGUAGIFTS_PAPER_CRANES_ID() ||
                giftId == getGUAGIFTS_JEWELRY_ID()) {
            return 1;
        }

        if (giftId == getGUAGIFTS_PAPER_ID() ||
                giftId == getGUAGIFTS_SOUR_LEMON_ID() ||
                giftId == getGUAGIFTS_DOG_FOOD_ID()) {
            return 2;
        }

        return 0;
    }
}
